//
// RS Game Framework
// Copyright © 2009 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#ifndef RS_CORE_HPP
#define RS_CORE_HPP

#include "rs/MetaFacilities.hpp"
#include "rs/Portability.hpp"

namespace rs
{
#	define RS_OFFSET_OF(class_name, member) \
		((RsSize) &(reinterpret_cast< class_name* >(0x1000)->member) - 0x1000)
	
	template< typename T >
    void BranchlessTernary(bool test, T t, T f, T& result) {
        RS_ALT_STATIC_ASSERT(meta::IsFundamentalType< T >::Value || meta::IsPointer< T >::Value);
        T const val = ~(static_cast< T >(test) - 1);
        result = (t & val) | (f & ~val);
    }
	
    template< typename T >
    struct TypeID
    {
        static IntPtr GetID() {
            return reinterpret_cast< IntPtr >(&id);
        }
        
    private:
        
        static int const id = 0;
    };
    
    template< typename T > int const TypeID< T >::id;
}

#endif // RS_CORE_HPP